<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>Deno Demo</title>
    <script src="https://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<style>
    body {
        background: #e6e4e4;
        margin: 0 auto;
        padding: 0;
    }
    
    .container {
        text-align: center;
    }
    
    .container .img {
        margin-top: 15%;
    }
    
    .container .text {
        font-size: 2rem;
        color: #2196F3;
        vertical-align: middle;
        position: fixed;
        top: 50%;
        left: 50%;
        width: 100%;
        height: 50%;
        -webkit-transform: translateX(-50%) translateY(-50%);
    }
    
    .container .time {
        font-size: 1rem;
        color: #009688;
        margin-top: 25%;
    }
</style>

<body>
    <div class="container">
        <div class="img"><img src="/static/img/logo.svg" width="80"></div>
        <div class="text">Hello Deno !</div>
        <div class="time"></div>
    </div>
</body>
<script>
    function getNowTime(url, config = {}) {
        return fetch(url, config)
            .then(res => res.json())
            .then(res => {
                const {
                    code,
                    data = {},
                    msg
                } = res;
                if (code != 200) {
                    throw new Error(msg);
                }
                return res;
            })
    }

    function fetTime() {
        var url = '/api/nowtime';
        var param = {
            method: 'get'
        }
        getNowTime(url).then(res => {
            $('.time').text(res.msg);
        });
    }
    $(function() {
        fetTime();
        setInterval("fetTime()", 1000)
    });
</script>

</html>